package com.helpustotravel.servlet;

import java.io.IOException;
import java.util.Calendar;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.helpustotravel.core.ServletBase;
import com.helpustotravel.model.analyse.ActivityAnalyse;

@SuppressWarnings("serial")
public class GetActivityAnalyseServlet extends ServletBase {

	public static String NAME = "GetActivityAnalyse";
	
	protected HttpServletResponse doTache(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		
		ActivityAnalyse activityAnalyse = new ActivityAnalyse(pm);
		
		Calendar calToday = Calendar.getInstance();
		Calendar calLastWeek = (Calendar)calToday.clone();
		calLastWeek.add(Calendar.WEEK_OF_YEAR, -1);		
		
		resp.setContentType("text/html");
		resp.getWriter().append(activityAnalyse.generateReport(calLastWeek.getTime(), calToday.getTime()));
		
		return resp;
	}
}
